package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: liangyuanzhang
 * Date: 2025-3-08
 * Time: 10:17
 */
public class Test {
    //将字符串中的大写字母转换成相同的小写字母，返回新字符串
    public String toLowerCase(String s){
        StringBuffer stringBuffer = new StringBuffer();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            // 判断当前字符 是不是字母
            if (Character.isLetter(ch)){
                // 判断当前字符 是不是大写
                if (Character.isUpperCase(ch)){
                    ch = (char)(ch + 32);
                }
            }
            stringBuffer.append(ch);
        }
        return stringBuffer.toString();// Buffer更安全，但是效率较低
    }


}
